/// Android原生登录响应模型
/// 对应Android的ApiUserInfoLogin类
class ApiUserInfoLogin {
  /// 用户Token
  final String userToken;
  
  /// 用户详细信息
  final ApiUserInfo userInfo;
  
  /// 是否首次登录 (1:是 2:否)
  final int isFirstLogin;
  
  /// 新手礼包列表
  final List<dynamic>? packList;
  
  /// 是否显示首充 (1:不显示 0:显示)
  final int isFirstRecharge;
  
  /// 是否能开播 (1:否 0:是)
  final int isLive;
  
  /// 是否可发布动态 (1:否 0:是)
  final int isVideo;
  
  /// VIP状态 (0:非VIP 1:VIP)
  final int vipType;
  
  /// 关注状态 (0:未关注 1:已关注)
  final int followStatus;
  
  /// 是否弹出邀请码 (1:弹出 2:不弹出)
  final int isPid;
  
  /// 商城Token
  final String? s2b2cConsumerToken;
  
  /// 用户头像ID
  final int? userAvatarId;
  
  ApiUserInfoLogin({
    required this.userToken,
    required this.userInfo,
    this.isFirstLogin = 2,
    this.packList,
    this.isFirstRecharge = 1,
    this.isLive = 1,
    this.isVideo = 1,
    this.vipType = 0,
    this.followStatus = 0,
    this.isPid = 2,
    this.s2b2cConsumerToken,
    this.userAvatarId,
  });
  
  factory ApiUserInfoLogin.fromJson(Map<String, dynamic> json) {
    return ApiUserInfoLogin(
      userToken: json['user_token'] as String? ?? '',
      userInfo: ApiUserInfo.fromJson(json['userInfo'] as Map<String, dynamic>? ?? {}),
      isFirstLogin: (json['isFirstLogin'] as num?)?.toInt() ?? 2,
      packList: json['packList'] as List<dynamic>?,
      isFirstRecharge: (json['isFirstRecharge'] as num?)?.toInt() ?? 1,
      isLive: (json['isLive'] as num?)?.toInt() ?? 1,
      isVideo: (json['isVideo'] as num?)?.toInt() ?? 1,
      vipType: (json['vipType'] as num?)?.toInt() ?? 0,
      followStatus: (json['followStatus'] as num?)?.toInt() ?? 0,
      isPid: (json['isPid'] as num?)?.toInt() ?? 2,
      s2b2cConsumerToken: json['s2b2cConsumerToken'] as String?,
      userAvatarId: (json['userAvatarId'] as num?)?.toInt(),
    );
  }
  
  Map<String, dynamic> toJson() {
    return {
      'user_token': userToken,
      'userInfo': userInfo.toJson(),
      'isFirstLogin': isFirstLogin,
      'packList': packList,
      'isFirstRecharge': isFirstRecharge,
      'isLive': isLive,
      'isVideo': isVideo,
      'vipType': vipType,
      'followStatus': followStatus,
      'isPid': isPid,
      's2b2cConsumerToken': s2b2cConsumerToken,
      'userAvatarId': userAvatarId,
    };
  }
  
  @override
  String toString() {
    return 'ApiUserInfoLogin(userToken: $userToken, userInfo: $userInfo, isFirstLogin: $isFirstLogin)';
  }
}

/// 用户详细信息模型
/// 对应Android的ApiUserInfo类
class ApiUserInfo {
  // 基础信息
  final int userId;
  final String? username;
  final String? mobile;
  final String? avatar;
  final String? nickname;
  final int sex; // 0:保密 1:男 2:女
  final String? birthday;
  final int? age;
  
  // 等级信息
  final int? userGrade;
  final int? anchorGrade;
  final int? wealthGrade;
  final int? nobleGrade;
  
  // 资产信息
  final double? coin;
  final double? ticket;
  final double? commission;
  
  // 认证状态
  final int? isAnchor; // 0:否 1:是
  final int? isAuth;
  
  // 个人信息
  final String? signature;
  final String? province;
  final String? city;
  final String? constellation;
  final int? height;
  final double? weight; // 体重可能是小数
  
  // 统计数据
  final int? fansNum;
  final int? attentionNum;
  final int? videoNum;
  final int? likeNum;
  
  // 其他
  final int? roomId;
  final int? liveStatus;
  final double? lat;
  final double? lng;
  
  ApiUserInfo({
    required this.userId,
    this.username,
    this.mobile,
    this.avatar,
    this.nickname,
    this.sex = 0,
    this.birthday,
    this.age,
    this.userGrade,
    this.anchorGrade,
    this.wealthGrade,
    this.nobleGrade,
    this.coin,
    this.ticket,
    this.commission,
    this.isAnchor,
    this.isAuth,
    this.signature,
    this.province,
    this.city,
    this.constellation,
    this.height,
    this.weight,
    this.fansNum,
    this.attentionNum,
    this.videoNum,
    this.likeNum,
    this.roomId,
    this.liveStatus,
    this.lat,
    this.lng,
  });
  
  factory ApiUserInfo.fromJson(Map<String, dynamic> json) {
    return ApiUserInfo(
      userId: (json['userId'] as num?)?.toInt() ?? 0,
      username: json['username'] as String?,
      mobile: json['mobile'] as String?,
      avatar: json['avatar'] as String?,
      nickname: json['nickname'] as String?,
      sex: (json['sex'] as num?)?.toInt() ?? 0,
      birthday: json['birthday'] as String?,
      age: (json['age'] as num?)?.toInt(),
      userGrade: (json['userGrade'] as num?)?.toInt(),
      anchorGrade: (json['anchorGrade'] as num?)?.toInt(),
      wealthGrade: (json['wealthGrade'] as num?)?.toInt(),
      nobleGrade: (json['nobleGrade'] as num?)?.toInt(),
      coin: (json['coin'] as num?)?.toDouble(),
      ticket: (json['ticket'] as num?)?.toDouble(),
      commission: (json['commission'] as num?)?.toDouble(),
      isAnchor: (json['isAnchor'] as num?)?.toInt(),
      isAuth: (json['isAuth'] as num?)?.toInt(),
      signature: json['signature'] as String?,
      province: json['province'] as String?,
      city: json['city'] as String?,
      constellation: json['constellation'] as String?,
      height: (json['height'] as num?)?.toInt(),
      weight: (json['weight'] as num?)?.toDouble(), // 体重是double
      fansNum: (json['fansNum'] as num?)?.toInt(),
      attentionNum: (json['attentionNum'] as num?)?.toInt(),
      videoNum: (json['videoNum'] as num?)?.toInt(),
      likeNum: (json['likeNum'] as num?)?.toInt(),
      roomId: (json['roomId'] as num?)?.toInt(),
      liveStatus: (json['liveStatus'] as num?)?.toInt(),
      lat: (json['lat'] as num?)?.toDouble(),
      lng: (json['lng'] as num?)?.toDouble(),
    );
  }
  
  Map<String, dynamic> toJson() {
    return {
      'userId': userId,
      'username': username,
      'mobile': mobile,
      'avatar': avatar,
      'nickname': nickname,
      'sex': sex,
      'birthday': birthday,
      'age': age,
      'userGrade': userGrade,
      'anchorGrade': anchorGrade,
      'wealthGrade': wealthGrade,
      'nobleGrade': nobleGrade,
      'coin': coin,
      'ticket': ticket,
      'commission': commission,
      'isAnchor': isAnchor,
      'isAuth': isAuth,
      'signature': signature,
      'province': province,
      'city': city,
      'constellation': constellation,
      'height': height,
      'weight': weight,
      'fansNum': fansNum,
      'attentionNum': attentionNum,
      'videoNum': videoNum,
      'likeNum': likeNum,
      'roomId': roomId,
      'liveStatus': liveStatus,
      'lat': lat,
      'lng': lng,
    };
  }
  
  @override
  String toString() {
    return 'ApiUserInfo(userId: $userId, username: $username, nickname: $nickname, mobile: $mobile)';
  }
}

